<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="description" content="" />
<meta name="author" content="ChongMing" />
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-touch-fullscreen" content="yes">
<meta name="full-screen" content="yes">
<meta name="screen-orientation" content="portrait">
<meta name="x5-fullscreen" content="true">
<meta name="360-fullscreen" content="true">
<title>订单详情</title>
</head>
<link rel="stylesheet" href="../css/framework7.ios.min.css">
<link rel="stylesheet" href="../css/framework7.ios.colors.min.css">
<link rel="stylesheet" href="../css/my-app.css">
<link rel="stylesheet" href="../css/reset.css">
<link rel="stylesheet" href="css/consultation.css">
<script src="../js/jquery-1.7.1.min.js"></script>
<script src="../js/jquery.mobile-1.4.3.js"></script>
<script type="text/javascript" src="../js/framework7.min.js"></script>
<script type="text/javascript" src="../js/my-app.js"></script>
<script src="js/consultation.js"></script>
<script src="../js/jquery.cookie.js"></script>
<script src="js/ap.js"></script>
<script src="js/pingpp.js"></script>
<script>
    $(function(){
        $.ajax({
            type: 'GET',
            url: url + '/diagnosis/orderdetail/',
            data: {         // 需要于客户端同步
                uid: $.cookie("local_userId"),
                order_id: consultationinterface.getQueryString("order_id")
            },
            dataType: 'jsonp',
            jsonp: 'callback',
            success: function (result) {
                if (result.ret == 0) {
                    var data = result.data;
                    order_id = data.order_id;
                    status = data.status
                    console.log(data);
                    $('.groupconsultationh-datail .payment-layer .con .name .p2').html(data.family_name);
                    $('.groupconsultationh-datail .payment-layer .con .phone .p2').html(data.link_mobile);
                    $('.groupconsultationh-datail .payment-layer .con .money-num .p2').html('￥'+data.total_amount)
                    if(data.type==9){
                        if(data.status==1){
                            $('.order_stay .order-list').append('<div class="order-detail"><div class="order-num">订单编号：'+data.order_no+'</div><div class="expert"><img src="'+data.pic+'"><div class="allexpert"><p class="tit">会诊专家：</p><ul></ul></div></div><div class="type"><div class="div1 public">类型：<b>会诊</b></div><div class="div2 public">科室：<b>'+ data.department_name+'</b></div><div class="div3 public">状态：<b>未付款</b></div></div><div class="amount"><span>会诊金额：<b>￥'+data.total_amount+'</b></span><button>立即付款</button></div></div>');
                            $.each(data.doctor_list,function(i,t){
                               $('.order_stay .order-list .order-detail .expert .allexpert ul').append('<li><p class="name">'+ t.user_name+'</p><p class="position">'+ t.job_name+'</p><p class="hospital">'+ t.hospital_name+'</p></li>');
                            });
                        }else if(data.status==2){
                            $('.order_stay .order-list').append('<div class="order-detail"><div class="order-num">订单编号：'+data.order_no+'</div><div class="expert"><img src="'+data.pic+'"><div class="allexpert"><p class="tit">会诊专家：</p><ul></ul></div></div><div class="type"><div class="div1 public">类型：<b>会诊</b></div><div class="div2 public">科室：<b>'+ data.department_name+'</b></div><div class="div3 public">状态：<b>已付款</b></div></div><div class="amount"><span>会诊金额：<b>￥'+data.total_amount+'</b></span></div></div>');
                            $.each(data.doctor_list,function(i,t){
                                $('.order_stay .order-list .order-detail .expert .allexpert ul').append('<li><p class="name">'+ t.user_name+'</p><p class="position">'+ t.job_name+'</p><p class="hospital">'+ t.hospital_name+'</p></li>');
                            });
                        }else if(data.status==4){
                            $('.order_stay .order-list').append('<div class="order-detail"><div class="order-num">订单编号：'+data.order_no+'</div><div class="expert"><img src="'+data.pic+'"><div class="allexpert"><p class="tit">会诊专家：</p><ul></ul></div></div><div class="type"><div class="div1 public">类型：<b>会诊</b></div><div class="div2 public">科室：<b>'+ data.department_name+'</b></div><div class="div3 public">状态：<b>已付款</b></div></div><div class="amount"><span>会诊金额：<b>￥'+data.total_amount+'</b></span><button style=" background: #44b181;">去评论</button></div></div>');
                            $.each(data.doctor_list,function(i,t){
                                $('.order_stay .order-list .order-detail .expert .allexpert ul').append('<li><p class="name">'+ t.user_name+'</p><p class="position">'+ t.job_name+'</p><p class="hospital">'+ t.hospital_name+'</p></li>');
                            });
                        }
                    }else if(data.type==10){
                        if(data.status==1){
                            $('.order_stay .order-list').append('<div class="order-detail"><div class="order-num">订单编号：'+ data.order_no+'</div><div data-id="'+ data.order_id+'" class="expert"><img src="'+data.pic+'"><div class="allexpert"><p class="tit">帮我推荐：</p><div class="divstay">正在与您取得联系</div></div></div><div class="type"><div class="div1 public">类型：<b>会诊</b></div><div class="div2 public">类型：<b>------</b></div><div class="div3 public">类型：<b>未付款</b></div></div><div class="amount"><span>会诊金额：<b>￥'+ data.total_amount+'</b></span><button class=" ui-btn ui-shadow ui-corner-all">立即付款</button></div></div>');
                            $.each(data.doctor_list,function(i,t){
                                $('.order_stay .order-list .order-detail .expert .allexpert ul').append('<li><p class="name">'+ t.user_name+'</p><p class="position">'+ t.job_name+'</p><p class="hospital">'+ t.hospital_name+'</p></li>');
                            });
                        }else if(data.status==2){
                            $('.order_stay .order-list').append('<div class="order-detail"><div class="order-num">订单编号：'+ data.order_no+'</div><div data-id="'+ data.order_id+'" class="expert"><img src="'+data.pic+'"><div class="allexpert"><p class="tit">帮我推荐：</p><div class="divstay">正在与您取得联系</div></div></div><div class="type"><div class="div1 public">类型：<b>会诊</b></div><div class="div2 public">类型：<b>------</b></div><div class="div3 public">类型：<b>已付款</b></div></div><div class="amount"><span>会诊金额：<b>￥'+ data.total_amount+'</b></span></div></div>');
                            $.each(data.doctor_list,function(i,t){
                                $('.order_stay .order-list .order-detail .expert .allexpert ul').append('<li><p class="name">'+ t.user_name+'</p><p class="position">'+ t.job_name+'</p><p class="hospital">'+ t.hospital_name+'</p></li>');
                            });
                        }else if(data.status==4){
                            $('.order_stay .order-list').append('<div class="order-detail"><div class="order-num">订单编号：'+data.order_no+'</div><div class="expert"><img src="'+data.pic+'"><div class="allexpert"><p class="tit">会诊专家：</p><ul></ul></div></div><div class="type"><div class="div1 public">类型：<b>会诊</b></div><div class="div2 public">科室：<b>'+ data.department_name+'</b></div><div class="div3 public">状态：<b>已付款</b></div></div><div class="amount"><span>会诊金额：<b>￥'+data.total_amount+'</b></span><button style=" background: #44b181;">去评论</button></div></div>');
                            $.each(data.doctor_list,function(i,t){
                                $('.order_stay .order-list .order-detail .expert .allexpert ul').append('<li><p class="name">'+ t.user_name+'</p><p class="position">'+ t.job_name+'</p><p class="hospital">'+ t.hospital_name+'</p></li>');
                            });
                        }
                    }
                    if(data.is_review==1){
                        $('.order_stay .order-list .order-detail .amount button').hide();
                    }
                } else {
                    alert(result.msg);
                }
            }
        });
        $(document).on('click','.order_stay .order-list .order-detail .amount button',function(){
            if(status==4){
                location.href = '../groupconsultation/publish-comment.html?order_id='+order_id
            }else{
                $('.payment-layer').show();
                $('.groupconsultationh-datail .payment-layer .con').animate({'bottom':0},300);
            }
        });
        code = consultationinterface.getQueryString("code");
        if(code){
            var order_id = consultationinterface.getQueryString("order_id");
            $.ajax({
                type: 'GET',
                url:  url + '/diagnosis/getcharge/',
                data: {         // 需要于客户端同步
                    uid: $.cookie("local_userId"),
                    order_id:order_id ,
                    pay_method:"wx_pub",
                    code : code
                },
                dataType: 'jsonp',
                jsonp: 'callback',
                success: function (result) {
                    if(result.ret==0){
                        pingpp.createPayment(result.data.charge, function(result, err) {
                            if (result=="success") {
                                location.href = '../groupconsultation/order_stayDiagnosis.html'
                            } else {
                                alert(result.data.msg)
                                console.log(result.data.msg)
                            }
                        });
                    }else{
                        alert(result.data.msg)
                        console.log(result.data.msg)
                    }

                }
            });
        }
        //    点击支付
        $('.groupconsultationh-datail .payment-layer .con .button-pay').click(function(){
//            var coupon_id = $('.groupconsultationh-datail .payment-layer .con .coupon .p-left').data('id');
            if($('.groupconsultationh-datail .payment-layer .con .pay-mode .wechat .radio').hasClass('hover')){
                pay_mode = 'wx_pub';
            }else{
                pay_mode = 'alipay_wap';
            }
            var success_url_sp = decodeURI(location.href);
            success_url = success_url_sp.split('?')[0]
            $.ajax({
                type: 'GET',
                url:  url + '/diagnosis/getcharge/',
                data: {         // 需要于客户端同步
                    uid: $.cookie("local_userId"),
                    order_id: order_id,
                    success_url:success_url,
                    pay_method:pay_mode
                },
                dataType: 'jsonp',
                jsonp: 'callback',
                success: function (result) {
                    if(result==0){
                        alert('ok')
                    }else{
                        console.log(result.msg)
                    }
                    if(pay_mode == "alipay_wap"){
                        pingpp.createPayment(result.data.charge, function(result, err) {
                            if (result=="success") {
                                location.href = '../groupconsultation/order_stayDiagnosis.html'
                            } else {

                            }
                        });
                    }else{
                        var url = result.data.location_url;
                        location.href = url;
                    }
                }
            });
        });
    });
</script>
<body>
<div class="order_stay order">
    <div class="order-list">

    </div>
</div>
<div class="groupconsultationh-datail">
    <div class="payment-layer">
        <div class="topmask"></div>
        <div class="con">
            <div class="name">
                <p class="p1">姓名：</p>
                <p class="p2">张三李四</p>
            </div>
            <div class="phone">
                <p class="p1">联系电话：</p>
                <p class="p2">156 0000 1234</p>
            </div>
            <div class="money-num">
                <p class="p1">实付金额</p>
                <p class="p2">￥ 1499</p>
            </div>
            <div class="pay-mode">
                <p class="p1">支付方式</p>
                <div class="wechat public">
                    <img class="icon-wechat img" src="images/icon42.png">
                    <img class="radio hover" src="images/icon41.png">
                </div>
                <div class="alipay public">
                    <img class="icon-alipay img" src="images/icon43.png">
                    <img class="radio" src="images/icon40.png">
                </div>
            </div>
            <span class="contact-time">推荐成功后2小时（工作时间段）可见联系电话</span>
            <button class="button-pay">支付</button>
        </div>
    </div>
</div>

</body>
</html>